﻿
function agree_onclick_emailReg()
{
	document.form_emailRegActive.agree.checked==""
	if(document.form_emailRegActive.agree.checked=="")
	{
		document.form_emailRegActive.submitb.disabled=true;
		document.getElementById("submitb").className="tianya_btn_gray";
		//document.form_emailRegActive.submitb.disabled=true;
	}
	else
	{
		document.form_emailRegActive.submitb.disabled=false;
		document.getElementById("submitb").className="tianya_btn";
	}
}

function CheckEmailPWDFunc(){
	var ResultContent_CheckEmailPWD;
	var CheckEmailPWD_length = document.forms['form_emailRegActive'].passwd.value.length;
	//alert(CheckPWD);
	if (CheckEmailPWD_length == 0)
	{
		document.getElementById("passwd").style.backgroundColor = "";
		document.getElementById("passwd").style.color = "";	
		ResultContent_CheckEmailPWD='';
		document.getElementById("CheckEmailPWDResult").innerHTML = ResultContent_CheckEmailPWD;
		return (false);
	}
	if (CheckEmailPWD_length >0 && CheckEmailPWD_length < 6)
	{
		document.getElementById("passwd").style.backgroundColor = "#FFCCCC";
		document.getElementById("passwd").style.color = "#000000";
		ResultContent_CheckEmailPWD='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">用户密码至少6位</FONT>';
		document.getElementById("CheckEmailPWDResult").innerHTML = ResultContent_CheckEmailPWD;
		//document.form_emailRegActive.passwd.focus();
		return (false);
	}
	else if (CheckEmailPWD_length > 16)
	{
		document.getElementById("passwd").style.backgroundColor = "#FFCCCC";
		document.getElementById("passwd").style.color = "#000000";
		ResultContent_CheckEmailPWD='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">用户密码过长</FONT>';
		document.getElementById("CheckEmailPWDResult").innerHTML = ResultContent_CheckEmailPWD;
		//document.form_emailRegActive.passwd.focus();
		return (false);
	}
	else
	{
		document.getElementById("passwd").style.backgroundColor = "";
		document.getElementById("passwd").style.color = "";	
		ResultContent_CheckEmailPWD='<img src="http://id.tianya.cn/user/register/v6/images/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckEmailPWDResult").innerHTML = ResultContent_CheckEmailPWD;
		return (false);
	}
}

function CheckEmailPWDFunc2(){
	var ResultContent_CheckEmailPWD2;
	var CheckEmailPWD = document.forms['form_emailRegActive'].passwd.value;
	var CheckEmailPWD2 = document.forms['form_emailRegActive'].passwd2.value;
	//alert(CheckEmailPWD);
	//alert(CheckEmailPWD2);
	if (CheckEmailPWD2 != "" && CheckEmailPWD!= CheckEmailPWD2)
	{
		document.getElementById("passwd2").style.backgroundColor = "#FFCCCC";
		document.getElementById("passwd2").style.color = "#000000";
		ResultContent_CheckEmailPWD2='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">密码不匹配</FONT>';
		document.getElementById("CheckEmailPWDResult2").innerHTML = ResultContent_CheckEmailPWD2;
		//document.form_emailRegActive.passwd.focus();
		return (false);
	}
	else if (CheckEmailPWD2 != "" && CheckEmailPWD == CheckEmailPWD2)
	{
		document.getElementById("passwd2").style.backgroundColor = "";
		document.getElementById("passwd2").style.color = "";
		ResultContent_CheckEmailPWD2='<img src="http://id.tianya.cn/user/register/v6/images/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckEmailPWDResult2").innerHTML = ResultContent_CheckEmailPWD2;
		return (false);
	}
	else
	{
		document.getElementById("passwd2").style.backgroundColor = "";
		document.getElementById("passwd2").style.color = "";
		ResultContent_CheckEmailPWD2='';
		document.getElementById("CheckEmailPWDResult2").innerHTML = ResultContent_CheckEmailPWD2;
		return (false);
	}
}

function CheckPWDQuestionFunc(){
	var CheckPWDQuestion = document.forms['form1'].password_question.value;
	//alert(CheckPWDQuestion);
	if (CheckPWDQuestion == 12)
	{
		show('tt');
	}
	else
	{
		document.forms['form1'].password_question_special.value = "";
		hide('tt');
	}
	if (CheckPWDQuestion != 0)
	{
		ResultContent_CheckPWD='<img src="http://id.tianya.cn/user/register/v6/images/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckPWDQuestionResult").innerHTML = ResultContent_CheckPWD;
		return (false);
	}
	else
	{
		ResultContent_CheckPWD='';
		document.getElementById("CheckPWDQuestionResult").innerHTML = ResultContent_CheckPWD;
		return (false);
	}
}

//CheckEmailQuestionFunc 停用
function CheckEmailQuestionFunc(){
	var ResultContent_CheckEmailQuestion;
	var CheckEmailQuestion = document.forms['form_emailRegActive'].question.value.length;
	//alert(CheckPWDAnswer);
	if (CheckEmailQuestion == 0)
	{
		document.getElementById("question").style.backgroundColor = "";
		document.getElementById("question").style.color = "";
		ResultContent_CheckEmailQuestion='';
		document.getElementById("CheckEmailQuestionResult").innerHTML = ResultContent_CheckEmailQuestion;
		return (false);
	}
	else if (CheckEmailQuestion > 0 && (CheckEmailQuestion < 6 || CheckEmailQuestion > 30))
	{
		document.getElementById("question").style.backgroundColor = "#FFCCCC";
		document.getElementById("question").style.color = "#000000";
		ResultContent_CheckEmailQuestion='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">自定义问题太短</FONT>';
		document.getElementById("CheckEmailQuestionResult").innerHTML = ResultContent_CheckEmailQuestion;
		//document.form_emailRegActive.passwd.focus();
		return (false);
	}
	else
	{
		document.getElementById("question").style.backgroundColor = "";
		document.getElementById("question").style.color = "";
		ResultContent_CheckEmailQuestion='<img src="http://id.tianya.cn/user/register/v6/images/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckEmailQuestionResult").innerHTML = ResultContent_CheckEmailQuestion;
		return (false);
	}
}

function CheckEmailAnswerFunc(){
	var ResultContent_CheckEmailAnswer;
	var CheckEmailAnswer = document.forms['form_emailRegActive'].answer.value.length;
	//alert(CheckEmailAnswer);
	if (CheckEmailAnswer == 0)
	{
		document.getElementById("answer").style.backgroundColor = "";
		document.getElementById("answer").style.color = "";
		ResultContent_CheckEmailAnswer='';
		document.getElementById("CheckEmailAnswerResult").innerHTML = ResultContent_CheckEmailAnswer;
		return (false);
	}
	else if (CheckEmailAnswer > 0 && (CheckEmailAnswer < 2 || CheckEmailAnswer > 30))  //20090604
	{
		document.getElementById("answer").style.backgroundColor = "#FFCCCC";
		document.getElementById("answer").style.color = "#000000";
		ResultContent_CheckEmailAnswer='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">问题答案太短</FONT>';
		document.getElementById("CheckEmailAnswerResult").innerHTML = ResultContent_CheckEmailAnswer;
		//document.form_emailRegActive.passwd.focus();
		return (false);
	}
	else
	{
		document.getElementById("answer").style.backgroundColor = "";
		document.getElementById("answer").style.color = "";
		ResultContent_CheckEmailAnswer='<img src="http://id.tianya.cn/user/register/v6/images/icon_ok.gif" width="16" height="16">';
		document.getElementById("CheckEmailAnswerResult").innerHTML = ResultContent_CheckEmailAnswer;
		return (false);
	}
}

var ResultContent_CheckRegEmail;
function CheckRegEmailFunc(){
	var CheckRegEmail = document.forms['form_emailRegActive'].RegEmail.value;
	//alert(CheckRegEmail);
	if (CheckRegEmail == "")
	{
		document.getElementById("RegEmail").style.backgroundColor = "";
		document.getElementById("RegEmail").style.color = "";
		document.getElementById("CheckRegEmailResult").innerHTML = '';
		return (false);
	}
	else if (CheckRegEmail != "" && !isEmail_regEmail(Jtrim(CheckRegEmail)) )
	{ 
		document.getElementById("RegEmail").style.backgroundColor = "#FFCCCC";
		document.getElementById("RegEmail").style.color = "#000000";
		document.getElementById("CheckRegEmailResult").innerHTML = ResultContent_CheckRegEmail;
		//document.form_emailRegActive.RegEmail.focus();
		return (false);
	}
	else
	{
		document.getElementById("RegEmail").style.backgroundColor = "";
		document.getElementById("RegEmail").style.color = "";
		document.getElementById("CheckRegEmailResult").innerHTML = '<img src="http://id.tianya.cn/user/register/v6/images/icon_ok.gif" width="16" height="16">';
		return (false);
	}
}

function isEmail_regEmail (s)
{
        // Writen by david, we can delete the before code
        if (s.length > 100)
        {
				ResultContent_CheckRegEmail='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">Email地址长度不能超过100位!</FONT>';
                return false;
        }

         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int)$"
         var re = new RegExp(regu);
         if (s.search(re) != -1) {
               return true;
         } else {
			   	ResultContent_CheckRegEmail='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">邮箱地址无效</FONT>';
               return false;
         }
} 

function CheckEmailNameFunc(){
	var CheckEmailName = document.forms['form_emailRegActive'].username.value;
	//alert(CheckEmailName);
	if (CheckEmailName != ''){
		if (Jtrim(CheckEmailName) == "")
			return (false);
		else{
			document.getElementById("CheckEmailNameResult").innerHTML = '<font color=red>请稍等,检验中...</font>'; 
			CheckEmailName = oUrl(CheckEmailName);
			var url = 'http://id.tianya.cn/user/register/v6/v6_emailActive_ReturnXML_CheckEmailUserName.asp?username='+CheckEmailName+'';
			//alert(url);
			doGet_RegEmail_defaultPage(url); //返回showGet()

		}
	}else{
		document.getElementById("CheckEmailNameResult").innerHTML = ''; 
		document.getElementById("username").style.backgroundColor = "";
		document.getElementById("username").style.color = "";
	}
}
function showGet_RegEmail_defaultPage(){
	showResult_RegEmail_defaultPage(xmlHttp);
}

function showResult_RegEmail_defaultPage(x)
{
	var ResultContent_EmailName;
	//var Result_EmailName = parseInt(x.responseText);
	var Result_EmailName = x.responseText
	//alert(Result_EmailName);
	if (Result_EmailName==1)
	{
		ResultContent_EmailName='<img src="http://id.tianya.cn/user/register/v6/images/icon_ok.gif" width="16" height="16">&nbsp;<FONT COLOR="blue">'+document.forms['form_emailRegActive'].username.value+' 可使用</FONT>';
		document.getElementById("username").style.backgroundColor = "";
		document.getElementById("username").style.color = "";
	}
	if (Result_EmailName==2)
	{
		ResultContent_EmailName='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">用户名已使用</FONT>';
		document.getElementById("username").style.backgroundColor = "#FFCCCC";
		document.getElementById("username").style.color = "#000000";
	}
	if (Result_EmailName==3)
	{
		ResultContent_EmailName='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">用户名已被使用</FONT>';
		document.getElementById("username").style.backgroundColor = "#FFCCCC";
		document.getElementById("username").style.color = "#000000";
	}
	if (Result_EmailName==4)
	{
		ResultContent_EmailName='<img src="http://id.tianya.cn/user/register/v6/images/icon_errow.gif" width="16" height="16">&nbsp;<FONT COLOR="red">用户名不能是中文</FONT>';
		document.getElementById("username").style.backgroundColor = "#FFCCCC";
		document.getElementById("username").style.color = "#000000";
	}

	document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_EmailName;
}


//注意以下参数判断过滤 20081229
function RegEmailFunc(){
	var js_username = document.forms['form_emailRegActive'].username.value;
	var js_passwd = document.forms['form_emailRegActive'].passwd.value;
	var js_passwd2 = document.forms['form_emailRegActive'].passwd2.value;
	var js_question = document.forms['form_emailRegActive'].question.value;
	var js_answer = document.forms['form_emailRegActive'].answer.value;
	var js_RegEmail = document.forms['form_emailRegActive'].RegEmail.value;
	var js_strCheck_RegEmail = document.forms['form_emailRegActive'].strCheck.value;
	var js_pageKey_trans_RegEmail = document.forms['form_emailRegActive'].pageKey_trans.value;
	var js_validateCode_RegEmail = document.forms['form_emailRegActive'].validateCode_regEmail.value;
	var js_urlRef_RegEmail = document.forms['form_emailRegActive'].urlRef.value;

	//alert(js_username);
	//alert(js_passwd);
	//alert(js_passwd2);
	//alert(js_question);
	//alert(js_answer);
	//alert(js_RegEmail);
	//alert(js_strWriter_RegEmail);
	//alert(js_idWriter_RegEmail);
	//alert(js_Key_RegEmail);
	//alert(js_pageKey_trans_RegEmail);
	//alert(js_ForwardURL_RegEmail);
	//return (false);
	if (js_username != '' && js_passwd != '' && js_passwd2 != '' && js_question != '' && js_answer != '' && js_pageKey_trans_RegEmail != '' && js_validateCode_RegEmail != ''){
		if (Jtrim(js_username) == "" || Jtrim(js_passwd) == "" || Jtrim(js_passwd2) == "" || Jtrim(js_question) == "" || Jtrim(js_answer) == "" || Jtrim(js_pageKey_trans_RegEmail) == "" || Jtrim(js_validateCode_RegEmail) == "")
			return (false);
		else{
			if (!isEmail_regEmail(Jtrim(js_RegEmail)) && js_RegEmail!=="" )
			{
				ResultContent_RegEmail='<FONT COLOR="red">常用邮箱格式不正确</FONT>';
				document.getElementById("CheckRegEmailResult").innerHTML = ResultContent_RegEmail;
			}
			else
			{
				//document.getElementById("RegEmailResult").innerHTML = '<font color=red>请稍等,检验中...</font>'; 
				js_username = oUrl(js_username);
				js_passwd = oUrl(js_passwd);
				js_passwd2 = oUrl(js_passwd2);
				js_question = oUrl(js_question);
				js_answer = oUrl(js_answer);
				js_pageKey_trans_RegEmail = oUrl(js_pageKey_trans_RegEmail);
				js_validateCode_RegEmail = oUrl(js_validateCode_RegEmail);
				var url = 'http://id.tianya.cn/user/register/v6/v6_emailActive_reg_do_defaultPage.asp?username='+js_username+'&passwd='+js_passwd+'&passwd2='+js_passwd2+'&question='+js_question+'&answer='+js_answer+'&RegEmail='+js_RegEmail+'&strCheck='+js_strCheck_RegEmail+'&pageKey_trans='+js_pageKey_trans_RegEmail+'&validateCode='+js_validateCode_RegEmail+'&urlRef='+js_urlRef_RegEmail+'';
				//alert(url);
				doGet_RegEmail(url); //返回showGet()
			}
		}
	}
	else
	{
		ResultContent_RegEmail='<FONT COLOR="red">您有必填信息尚未填写,请填写完整</FONT>';
		document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_RegEmail;
	}
}
function showGet_RegEmail(){
	showResult_RegEmail(xmlHttp);
}

function showResult_RegEmail(x)
{
	var ResultContent_RegEmail;
	//var Result_RegEmail = parseInt(x.responseText);
	var Result_RegEmail = x.responseText
	//alert(Result_RegEmail);
	if (Result_RegEmail==1)
	{
		//20090604 start
		hide('div_regEmail');
		document.forms['form1'].e_mail.value = document.forms['form_emailRegActive'].username.value+"@tianya.cn";
		v8_CheckEMailFunc();
		//20090604 end

	}
	else if (Result_RegEmail==6)
	{
		ResultContent_RegEmail='<FONT COLOR="red">该IP已达到今天的允许注册数</FONT>';
		document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_RegEmail;
	}
	//else if (Result_RegEmail==7)
	//{
	//	ResultContent_RegEmail='<FONT COLOR="red">您有必填信息尚未填写,请填写完整</FONT>';
	//	document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_RegEmail;
	//}
	else if (Result_RegEmail==8)
	{
		ResultContent_RegEmail='<FONT COLOR="red">您两次密码填写不一致,请重新填写</FONT>';
		document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_RegEmail;
	}
	else if (Result_RegEmail==9)
	{
		ResultContent_RegEmail='<FONT COLOR="red">用户名已被使用</FONT>';
		document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_RegEmail;
	}
	else if (Result_RegEmail==10)
	{
		ResultContent_RegEmail='<FONT COLOR="red">验证码不正确</FONT>';
		document.getElementById("validateCodeResult_regEmail").innerHTML = ResultContent_RegEmail;
	}
	else if (Result_RegEmail==11)
	{
		ResultContent_RegEmail='<FONT COLOR="red">邮件发送失败,请确认是否填写正确</FONT>';
		document.getElementById("validateCodeResult_regEmail").innerHTML = ResultContent_RegEmail;
	}
	else if (Result_RegEmail==12)
	{
		ResultContent_RegEmail='<FONT COLOR="red">用户名不能是中文</FONT>';
		document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_RegEmail;
	}
	else if (Result_RegEmail==13 || Result_RegEmail==14 || Result_RegEmail==15 || Result_RegEmail==16 || Result_RegEmail==17 || Result_RegEmail==18 || Result_RegEmail==19 || Result_RegEmail==20 || Result_RegEmail==21)
	{
		ResultContent_RegEmail='<FONT COLOR="red">验证码不正确'+Result_RegEmail+'</FONT>';
		document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_RegEmail;
	}
	else
	{
		ResultContent_RegEmail='<FONT COLOR="red">用户名已被使用</FONT>';
		document.getElementById("CheckEmailNameResult").innerHTML = ResultContent_RegEmail;
	}
}